<?php


namespace app\api\controller;


use app\common\controller\Api;
use app\common\model\Prediction as PredictionModel;
use app\common\model\PredictionResult;

class Prediction extends Api
{
    protected $noNeedLogin = '*';

    /**
     * 列表
     */
    public function list()
    {
        $data = PredictionModel::all();
        $this->success('', $data);
    }

    /**
     * 结果
     * @param int $cod
     * @param int $tn
     * @param int $nh
     * @param float $tp
     * @param int $ph
     * @param int $temp
     */
    public function detail()
    {
        $where_sql['cod'] = input('cod');
        $where_sql['tn'] = input('tn');
        $where_sql['nh'] = input('nh');
        $where_sql['tp'] = input('tp');
        $where_sql['ph'] = input('ph');
        $where_sql['temp'] = input('temp');
        $prediction_id = PredictionModel::where($where_sql)->value('id');
        if (!$prediction_id) {
            $prediction_id = 0;
        }
        $data = PredictionResult::where('prediction_id', $prediction_id)->select();
        $this->success('', $data);
    }
}